-
Notifications
You must be signed in to change notification settings - Fork 320
Fix/contract message signatures #2526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/contract message signatures #2526
Conversation
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
* Fix 1271 contract signatures * Closes #2535 and #2526 * Add migration to delete contract signatures * Add docs --------- Co-authored-by: Uxio Fuentefria <[email protected]>
|
Implemented in #2539 |
Update 2025-05-22
After lengthy internal discussion, it was determined that the current behaviour is correct for
SafeandCompatibilityFallbackHandlerv1.3.0, while the proposed changes here are required for Safe v1.4.1+.Additionally, note that the
CompatibilityFallbackHandlerv1.3.0 will not work with Safe v1.4.1 for contract owner signatures, because thedataHash == keccak256(data)invariant is not being respected.What was wrong? 👾
It looks like the Safe transaction service is not correctly validating contract signatures for Safe messages. It uses the wrong preimage value for simulating the contract
isValidSignaturecall which causes invalid signatures to be accepted, but valid signatures to be rejected.As proof, you can "trick" the transaction service by uploading a signature for
keccak256(keccak256(SafeMessage.message)). For example, the following signature was accepted by the safe transaction service despite not being valid:https://app.safe.global/transactions/msg?safe=sep:0x2eB2E943a7877fcbC404351D7c8Ca5853B1a93D6&messageHash=0xe7ad065df60ded50e5c36a69333c2364f7592feeabfbba9ad0a17c74946d02ae
Here is a reverting simulation when trying to use the signature with
isValidSignature:https://www.tdly.co/shared/simulation/c58211dd-8e6a-40af-a935-5cb97da878a3
How was it fixed? 🎯
Using the correct pre-image for the Safe contract signatures. Depends on safe-global/safe-eth-py#1655.
Notes
I created this as a draft PR, but it is more like an issue 😅. I just thought it would be easier to point out where the exact problem is.